<?php


namespace App\Controller\Test;


use App\Controller\BaseController;

use App\JsonRpc\CalculatorServiceInterface;
use App\JsonRpc\RGiftServiceInterface;
use Hyperf\Context\ApplicationContext;
use Hyperf\HttpServer\Annotation\AutoController;

#[AutoController]
class MicroController extends BaseController
{
    public function sum()
    {
        $num1 = $this->request->post('num1', 1);
        $num2 = $this->request->post('num2', 1);
        $client = ApplicationContext::getContainer()->get(CalculatorServiceInterface::class);
        return $client->sum($num1, $num2);

    }

    public function sumPro()
    {
        $num1 = $this->request->post('num1', 1);
        $num2 = $this->request->post('num2', 1);
        $client = ApplicationContext::getContainer()->get(CalculatorServiceInterface::class);
        return $client->sumPro($num1, $num2);

    }

    public function giftList()
    {
        $client = ApplicationContext::getContainer()->get(RGiftServiceInterface::class);
        $userInfo['uid'] = 1000048;
        $userInfo['sex'] = 1;
        $userInfo['guild_num'] = '';
        $userInfo['send_gift_rate'] = 0.4;
        $params['user_id'] = 1000055;
        return $client->list($userInfo, $params);
    }

    public function giftCreate()
    {
        $client = ApplicationContext::getContainer()->get(RGiftServiceInterface::class);
        $params['name'] = $this->request->post('name','name');
        $params['en_name'] = $this->request->post('en_name', 'en');
        $params['hk_name'] = $this->request->post('hk_name','hk');
        $params['img'] = $this->request->post('img','123.png');
        return $client->create($params);
    }

}